import random

from google.appengine.ext import webapp

import simplejson


BASES = {
    'base16': '0123456789ABCDEF',
    'base32': '0123456789ABCDEFGHJKMNPQRSTVWXYZ',
    'base64': 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
}

LENGTH = 64


class MainHandler(webapp.RequestHandler):
    def get(self):
        rnd = {}
        for base, symbols in BASES.items():
            rnd[base] = ''.join(map(lambda x: random.choice(symbols),
                xrange(0,LENGTH)))
        self.response.headers.add_header('Expires',
            'Mon, 01 Jan 1990 00:00:00 GMT')
        self.response.headers.add_header('Content-type', 'application/json')
        self.response.out.write(simplejson.dumps(rnd))
